package testMore;

import java.util.*;
import java.util.stream.Collectors;

public class Test102 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String s = scanner.nextLine();
            char[] chars = s.toCharArray();
            Map<Character,Integer> map = new TreeMap<>();
            for (int i = 0; i < chars.length; i++) {
                if (map.containsKey(chars[i])){
                    map.put(chars[i],map.get(chars[i])+1);
                }else{
                    map.put(chars[i],1);
                }
            }

            List<Integer> collect = map.values().stream().distinct().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
            for (Integer v:collect) {
                Set<Character> set = new TreeSet<>();
                for (Character c : map.keySet()) {
                    if (map.get(c).equals(v)){
                        set.add(c);
                    }
                }
                set.forEach(System.out::print);
            }

            System.out.println("");


        }
    }
}
